<!--/**-->
<!--* Created by TamTT on 1/13/14.-->
<!--* FPT University - Da Nang-->
<!--* Capstone project - group 3-->
<!--* Jornee-->
<!--*/-->
<!DOCTYPE html>
<html>
<head>
    <title><%= title %></title>
    <link rel='stylesheet' href='/stylesheets/style.css' />
    <script src="/javascripts/jquery-2.1.0.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            function login_ajax(){
                var name = $("#adminName").val();
                var pass = $("#adminPass").val();
                $.ajax({
                    url: '/admin_login_ajax',
                    type: 'POST',
                    data: { adminName: name, adminPass: pass },
                    dataType: 'JSON',
                    success: function(data) {
                        if(data.status == 'error'){
                            alert('Submit error! Please try again!');
                        } else if(data.status == 'fail'){
                            alert('Wrong name/pass');
                        } else {
                            window.location.replace('/this/is/admin/page/for/admin/only/hihi');
                        }
                    },
                    error: function() {
                        alert('Submit error! Please retry!');
                    }
                });
            }
            var key = 0;
            $(document).keydown(function(e) {
                if(e.which == 39){
                    key = 1;
                } else if(key == 1 && e.which == 37){
                    key = 2;
                } else if(key == 2 && e.which == 38){
                    key = 3;
                } else if(key == 3 && e.which == 40){
                    alert('Hey, you got a easter egg!')
                    login_ajax();
                }
            });

            $('#submitLogin').click(function(){
                login_ajax();
            });
        });
    </script>
</head>
<body>
<div id="top">
    <div id="topContainer">
        <div id="topLeft">
            <!--<h1>Jornee</h1>-->
            <h1>Admin Login</h1>
            <p>Welcome to admin login page. Are you really an admin?</p>
        </div>
        <div id="topRight">
            <img height="120" src="/images/logo_new.png">
        </div>
    </div>
</div>
<div id="formContainer" style="margin: 10% auto; width: 30%;">
    <table id="formContainerTable" style="text-align: right; width: 100%">
        <tr>
            <td>Admin name:</td>
            <td><input id="adminName" type="text" name="adminName" style="width: 100%"></td>
        </tr>
        <tr>
            <td>Password:</td>
            <td><input id="adminPass" type="password" name="adminPass" style="width: 100%"></td>
        </tr>
        <tr>
            <td></td>
            <td><button id="submitLogin" style="width: 50%">Login!</button></td>
        </tr>
    </table>
</div>
</body>
</html>